package com.ruoyi.basciSign.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basciSign.domain.BasicSign;
import com.ruoyi.basciSign.service.IBasicSignService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 徽章管理Controller
 * 
 * @author ruoyi
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/basciSign/basciSign")
public class BasicSignController extends BaseController
{
    @Autowired
    private IBasicSignService basicSignService;

    //    TODO 用户徽章，查询--徽章管理--列表
    /**
     * 查询--徽章管理--列表
     */
    @RequestMapping("/getBasicSign")
    public AjaxResult getBasicSign()
    {
        List<BasicSign> list = basicSignService.selectBasicSignList(new BasicSign());
        return success(list);
    }


    /**
     * 查询徽章管理列表
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicSign basicSign)
    {
        startPage();
        List<BasicSign> list = basicSignService.selectBasicSignList(basicSign);
        return getDataTable(list);
    }

    /**
     * 导出徽章管理列表
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:export')")
    @Log(title = "徽章管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicSign basicSign)
    {
        List<BasicSign> list = basicSignService.selectBasicSignList(basicSign);
        ExcelUtil<BasicSign> util = new ExcelUtil<BasicSign>(BasicSign.class);
        util.exportExcel(response, list, "徽章管理数据");
    }

    /**
     * 获取徽章管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicSignService.selectBasicSignById(id));
    }

    /**
     * 新增徽章管理
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:add')")
    @Log(title = "徽章管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicSign basicSign)
    {
        return toAjax(basicSignService.insertBasicSign(basicSign));
    }

    /**
     * 修改徽章管理
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:edit')")
    @Log(title = "徽章管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicSign basicSign)
    {
        return toAjax(basicSignService.updateBasicSign(basicSign));
    }

    /**
     * 删除徽章管理
     */
    @PreAuthorize("@ss.hasPermi('basciSign:basciSign:remove')")
    @Log(title = "徽章管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicSignService.deleteBasicSignByIds(ids));
    }
}
